﻿USE [master]
GO
/****** Object:  Database [Portal]    Script Date: 9/17/2013 6:27:24 PM ******/
CREATE DATABASE [Portal]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'Portal', FILENAME = N'C:\Users\PIJUSH__KANTI_BISWAS\Portal.mdf' , SIZE = 15424KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'Portal_log', FILENAME = N'C:\Users\PIJUSH__KANTI_BISWAS\Portal_log.ldf' , SIZE = 10368KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [Portal] SET COMPATIBILITY_LEVEL = 110
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Portal].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Portal] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [Portal] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [Portal] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [Portal] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [Portal] SET ARITHABORT OFF 
GO
ALTER DATABASE [Portal] SET AUTO_CLOSE ON 
GO
ALTER DATABASE [Portal] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [Portal] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [Portal] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [Portal] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [Portal] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [Portal] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [Portal] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [Portal] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [Portal] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [Portal] SET  ENABLE_BROKER 
GO
ALTER DATABASE [Portal] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [Portal] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [Portal] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [Portal] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [Portal] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [Portal] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [Portal] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [Portal] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [Portal] SET  MULTI_USER 
GO
ALTER DATABASE [Portal] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [Portal] SET DB_CHAINING OFF 
GO
ALTER DATABASE [Portal] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [Portal] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
USE [Portal]
GO
/****** Object:  User [root]    Script Date: 9/17/2013 6:27:24 PM ******/
CREATE USER [root] FOR LOGIN [root] WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_owner] ADD MEMBER [root]
GO
/****** Object:  Table [dbo].[Segments]    Script Date: 9/17/2013 6:27:24 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Segments](
	[SegmentId] [bigint] IDENTITY(1,1) NOT NULL,
	[FileId] [bigint] NULL,
	[OrderId] [int] NOT NULL,
	[Bytes] [varbinary](max) NULL,
	[StorageType] [nchar](10) NULL,
	[FullName] [nvarchar](2000) NULL,
	[Name] [nvarchar](500) NULL,
	[Updated] [datetime] NULL,
	[Created] [datetime] NULL,
	[Html] [nvarchar](max) NULL,
	[AppUser] [nvarchar](50) NULL,
 CONSTRAINT [PK_Segments] PRIMARY KEY CLUSTERED 
(
	[SegmentId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[WebFile]    Script Date: 9/17/2013 6:27:24 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WebFile](
	[FileId] [bigint] IDENTITY(1,1) NOT NULL,
	[FolderId] [bigint] NULL,
	[StorageType] [nchar](10) NULL,
	[FullName] [nvarchar](2000) NULL,
	[Name] [nvarchar](500) NULL,
	[Size] [bigint] NULL,
	[Updated] [datetime] NULL,
	[Created] [datetime] NULL,
	[Html] [nvarchar](max) NULL,
	[AppUser] [nvarchar](50) NULL,
 CONSTRAINT [PK_WebFile] PRIMARY KEY CLUSTERED 
(
	[FileId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[WebFolder]    Script Date: 9/17/2013 6:27:24 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WebFolder](
	[FolderId] [bigint] IDENTITY(1,1) NOT NULL,
	[ParentId] [bigint] NULL,
	[StorageType] [nchar](10) NULL,
	[FullName] [nvarchar](2000) NULL,
	[Name] [nvarchar](500) NULL,
	[Updated] [datetime] NULL,
	[Created] [datetime] NULL,
	[Html] [nvarchar](max) NULL,
	[AppUser] [nvarchar](50) NULL,
 CONSTRAINT [PK_WebFolder] PRIMARY KEY CLUSTERED 
(
	[FolderId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
ALTER TABLE [dbo].[Segments] ADD  CONSTRAINT [DF_Segments_Updated]  DEFAULT (getdate()) FOR [Updated]
GO
ALTER TABLE [dbo].[Segments] ADD  CONSTRAINT [DF_Segments_Created]  DEFAULT (getdate()) FOR [Created]
GO
ALTER TABLE [dbo].[WebFile] ADD  CONSTRAINT [DF_WebFile_Updated]  DEFAULT (getdate()) FOR [Updated]
GO
ALTER TABLE [dbo].[WebFile] ADD  CONSTRAINT [DF_WebFile_Created]  DEFAULT (getdate()) FOR [Created]
GO
ALTER TABLE [dbo].[WebFolder] ADD  CONSTRAINT [DF_WebFolder_Created1]  DEFAULT (getdate()) FOR [Updated]
GO
ALTER TABLE [dbo].[WebFolder] ADD  CONSTRAINT [DF_WebFolder_Created]  DEFAULT (getdate()) FOR [Created]
GO
ALTER TABLE [dbo].[Segments]  WITH CHECK ADD  CONSTRAINT [FK_Segments_WebFile] FOREIGN KEY([FileId])
REFERENCES [dbo].[WebFile] ([FileId])
GO
ALTER TABLE [dbo].[Segments] CHECK CONSTRAINT [FK_Segments_WebFile]
GO
ALTER TABLE [dbo].[WebFile]  WITH CHECK ADD  CONSTRAINT [FK_WebFile_WebFolder] FOREIGN KEY([FolderId])
REFERENCES [dbo].[WebFolder] ([FolderId])
GO
ALTER TABLE [dbo].[WebFile] CHECK CONSTRAINT [FK_WebFile_WebFolder]
GO
ALTER TABLE [dbo].[WebFolder]  WITH CHECK ADD  CONSTRAINT [FK_WebFolder_WebFolder] FOREIGN KEY([ParentId])
REFERENCES [dbo].[WebFolder] ([FolderId])
GO
ALTER TABLE [dbo].[WebFolder] CHECK CONSTRAINT [FK_WebFolder_WebFolder]
GO
USE [master]
GO
ALTER DATABASE [Portal] SET  READ_WRITE 
GO
